import { UPDATE_WEB_NAV_INDEX, UPDATE_TEST_DATA, AppActionTypes  } from './types'
import Store from '../index'
import { Dispatch } from 'redux'

/**
 * 更新web导航
 */
export function updateWebNavIndex(value: string): void {
  Store.dispatch({
    type: UPDATE_WEB_NAV_INDEX,
    value: value
  })
}

export function updateTest(value: number) {
  return (dispatch: Dispatch<AppActionTypes>) => {
    return new Promise((res, rej) => {
      setTimeout(() => {
        dispatch({
          type: UPDATE_TEST_DATA,
          value: value
        })
      }, 2000);
    })
  }
}